spinnerDom = null

start = ->
  spinnerDom = document.createElement('div')
  spinnerDom.className += ' cl spinner'
  spinnerDom.id = 'spinner'
  spinnerDom.innerHTML = '<i class="icon-spinner spin"></i>'
  document.body.appendChild spinnerDom

done = ->
  spinnerDom.className += ' hide' if spinnerDom?

remove = ->
  spinnerDom.parentNode.removeChild(spinnerDom) if spinnerDom?

document.addEventListener('page:fetch', start)
document.addEventListener('page:change', done)
document.addEventListener('page:restore', remove)